package com.dyc.caradvertisting.ui.fmt.bind.bs;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.dyc.caradvertisting.R;
import com.dyc.caradvertisting.event.ParamBrotherEvent;
import com.dyc.caradvertisting.ui.fmt.bind.bs.adapter.CarNumberAdpater;
import com.njh.tools.base.BaseFragment;

import org.greenrobot.eventbus.EventBus;

import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 选择车牌
 */
public class SelectCarNmberFmt extends BaseFragment {
    @BindView(R.id.lv_car_nuber)
    ListView lvCar;
    public CarNumberAdpater mCarNumberAdpater;
    public List<String> mCarNumber;
    public SelectCarNmberFmt() {
        // Required empty public constructor
    }

    public static SelectCarNmberFmt newInstance() {
        SelectCarNmberFmt fragment = new SelectCarNmberFmt();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return getView(inflater, container);
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_select_car_nmber_fmt;
    }

    @Override
    public void initView(View baseView) {

      initToolbarNav(R.string.tilte_car_number);
        ButterKnife.bind(this,baseView);
        mCarNumber=Arrays.asList(this._mActivity.getResources().getStringArray(R.array.car_number));
        mCarNumberAdpater=new CarNumberAdpater(mCarNumber,this.getContext());
        lvCar.setAdapter(mCarNumberAdpater);
        lvCar.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
               String number=mCarNumber.get(i);
                EventBus.getDefault().post(new ParamBrotherEvent(1,number));
                _mActivity.onBackPressed();
            }
        });
    }

    @Override
    public boolean isSwipeBack() {
        return true;
    }

    @Override
    public void initPresenter() {

    }


}
